import { Authorized as RenderAuthorized } from 'ant-design-pro'
import {getData} from './localData.js'

let Authorized = RenderAuthorized(getData('myAuthorized'))

// Reload the rights component
const reloadAuthorized = () => {
    Authorized = RenderAuthorized(getData('myAuthorized'));
};

const havePermission = (auth) => {
    return function (authorizedList){
        //console.log(authorizedList, auth)
        if(authorizedList.includes(auth)){
            return true
        }
        return false
    }
}

const haveAnyPermission = (authList) => {
    return function (authorizedList){
        let b = false
        authList.forEach(element => {
            if(authorizedList.includes(element)){
                b = true
            }
        });
        return b
    }
}


export { reloadAuthorized , havePermission, haveAnyPermission};
export default Authorized;